package com.tdlx.sonar;

import java.util.List;
import java.util.Map;

/**
 * 系统用户信息
 * @author Simple
 */
public class User {
	
	public static final String NAME = "User";
	
	//认证账号ID
	private Long credentialId;
	
	//员工ID
	private Long employeeId;
	
	//部门ID
	private Long departmentId;
	
	//部门名称
	private String departmentName;
	
	//企业ID
	private Long enterpriseId;
	
	//企业名称
	private String enterpriseName;
	
	//企业编码,用于组织层次关系
	private String enterpriseFlag;
	
	//员工姓名
	private String employeeName;
	
	//登陆名称
	private String loginName;
	
	//手机号码
	private String phone;
	
	//邮箱地址
	private String email;
	
	//企业前缀
	private String prefix;
	
	//上次登陆签名
	private String signature;
	
	//登陆账户状态
	private Integer status;
	
	//上次登陆时间
	private Long lastLoginTime;
	
	//用户类型
	private Integer type;
	
	private List<String> actionCodes;

	private Map<String,String> conf;
	
	public Long getCredentialId() {
		return credentialId;
	}

	public void setCredentialId(Long credentialId) {
		this.credentialId = credentialId;
	}

	public Long getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(Long employeeId) {
		this.employeeId = employeeId;
	}

	public Long getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Long departmentId) {
		this.departmentId = departmentId;
	}

	public Long getEnterpriseId() {
		return enterpriseId;
	}

	public void setEnterpriseId(Long enterpriseId) {
		this.enterpriseId = enterpriseId;
	}

	public String getEnterpriseFlag() {
		return enterpriseFlag;
	}

	public void setEnterpriseFlag(String enterpriseFlag) {
		this.enterpriseFlag = enterpriseFlag;
	}

	public String getEmployeeName() {
		return employeeName;
	}

	public void setEmployeeName(String employeeName) {
		this.employeeName = employeeName;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	public String getSignature() {
		return signature;
	}

	public void setSignature(String signature) {
		this.signature = signature;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Long getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Long lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public List<String> getActionCodes() {
		return actionCodes;
	}

	public void setActionCodes(List<String> actionCodes) {
		this.actionCodes = actionCodes;
	}
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getDepartmentName() {
		return departmentName;
	}

	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}

	public String getEnterpriseName() {
		return enterpriseName;
	}

	public void setEnterpriseName(String enterpriseName) {
		this.enterpriseName = enterpriseName;
	}

	/**
	 * 判断用户是否拥有指定权限
	 * @param code	权限编码
	 * @return
	 */
	public boolean hasAction(String code){
		if(null != code && actionCodes != null){
			for(String c : actionCodes){
				if(code.equals(c)){
					return true;
				}
			}
		}
		return false;
	}

	public Map<String, String> getConf() {
		return conf;
	}

	public void setConf(Map<String, String> conf) {
		this.conf = conf;
	}
	
	/**
	 * 判断并获取用户的指定配置信息
	 * @param key	配置键
	 * @return
	 */
	public String hasConf(String key){
		if(conf != null){
			return conf.get(key);
		}
		return null;
	}
}
